package com.projeto.persistence;

import com.projeto.infra.business.GenericEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;

/**
 * The persistent class for the receipt database table.
 *
 */
@Entity
public class Receipt extends GenericEntity implements Serializable {

    public static enum Status {

        PENDING("PENDING"),
        NEW("NEW"),
        SHIPPED("SHIPPED"),
        DELIVERED("DELIVERED");
        
        private final String label;

        private Status(String label) {
            this.label = label;
        }

        public String getLabel() {
            return label;
        }        
    }
    private static final long serialVersionUID = 1L;
    @Id
    private String id;
    private String description;
    private int number;
    private int pickup;
    @Enumerated(EnumType.ORDINAL)
    private Status status;
    private boolean inactive;
    
    @Column(name = "HAS_INVOICE")
    private boolean hasInvoice;

    @Column(name = "DELIVERED_BY")
    private String deliveredBy;
    //bi-directional many-to-one association to Customer
    @ManyToOne
    @JoinColumn(name = "FROM_CUSTOMER")
    private Customer shipper;
    //bi-directional many-to-one association to Usertable
    @ManyToOne
    @JoinColumn(name = "RECEIVED_BY")
    private User receivedBy;
    //bi-directional many-to-one association to Shipment
    @ManyToOne
    private Shipment shipment;
    //bi-directional many-to-one association to Customer
    @ManyToOne
    @JoinColumn(name = "TO_CUSTOMER")
    private Customer consignee;
    //bi-directional many-to-one association to ReceiptDetail
    @OneToMany(mappedBy = "receipt", cascade = CascadeType.ALL)
    private List<ReceiptDetail> receiptDetails;
    @Temporal( TemporalType.TIMESTAMP)
    @Column(name = "CREATE_DT")
    private Date createDt;
    @Temporal( TemporalType.TIMESTAMP)
    @Column(name = "UPDATE_DT")
    private Date updateDt;
    //bi-directional many-to-one association to Usertable
    @ManyToOne
    @JoinColumn(name = "CREATED_BY")
    private User createdBy;
    //bi-directional many-to-one association to Usertable
    @ManyToOne
    @JoinColumn(name = "UPDATED_BY")
    private User updatedBy;

    public Receipt() {
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getNumber() {
        return this.number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public int getPickup() {
        return this.pickup;
    }

    public void setPickup(int pickup) {
        this.pickup = pickup;
    }

    public String getDeliveredBy() {
        return this.deliveredBy;
    }

    public void setDeliveredBy(String deliveredBy) {
        this.deliveredBy = deliveredBy;
    }

    public Customer getShipper() {
        return this.shipper;
    }

    public void setShipper(Customer shipper) {
        this.shipper = shipper;
    }

    public User getReceivedBy() {
        return this.receivedBy;
    }

    public void setReceivedBy(User receivedBy) {
        this.receivedBy = receivedBy;
    }

    public Shipment getShipment() {
        return this.shipment;
    }

    public void setShipment(Shipment shipment) {
        this.shipment = shipment;
    }

    public Customer getConsignee() {
        return this.consignee;
    }

    public void setConsignee(Customer consignee) {
        this.consignee = consignee;
    }

    public List<ReceiptDetail> getReceiptDetails() {
        return this.receiptDetails;
    }

    public void setReceiptDetails(List<ReceiptDetail> receiptDetails) {
        this.receiptDetails = receiptDetails;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    @Override
    public Date getCreateDt() {
        return createDt;
    }

    @Override
    public void setCreateDt(Date createDt) {
        this.createDt = createDt;
    }

    @Override
    public Date getUpdateDt() {
        return updateDt;
    }

    @Override
    public void setUpdateDt(Date updateDt) {
        this.updateDt = updateDt;
    }

    @Override
    public User getCreatedBy() {
        return createdBy;
    }

    @Override
    public void setCreatedBy(User createdBy) {
        this.createdBy = createdBy;
    }

    @Override
    public User getUpdatedBy() {
        return updatedBy;
    }

    @Override
    public void setUpdatedBy(User updatedBy) {
        this.updatedBy = updatedBy;
    }

    public boolean isInactive() {
        return inactive;
    }

    public void setInactive(boolean inactive) {
        this.inactive = inactive;
    }

    public boolean isHasInvoice() {
        return hasInvoice;
    }

    public void setHasInvoice(boolean hasInvoice) {
        this.hasInvoice = hasInvoice;
    }

    @Override
    public String toString() {
        return "Receipt{" + "id=" + id + ", description=" + description + ", number=" + number + ", pickup=" + pickup + ", status=" + status + ", inactive=" + inactive + ", hasInvoice=" + hasInvoice + ", deliveredBy=" + deliveredBy + ", shipper=" + shipper + ", receivedBy=" + receivedBy + ", shipment=" + shipment + ", consignee=" + consignee + ", receiptDetails=" + receiptDetails + ", createDt=" + createDt + ", updateDt=" + updateDt + ", createdBy=" + createdBy + ", updatedBy=" + updatedBy + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 41 * hash + (this.description != null ? this.description.hashCode() : 0);
        hash = 41 * hash + this.number;
        hash = 41 * hash + this.pickup;
        hash = 41 * hash + (this.status != null ? this.status.hashCode() : 0);
        hash = 41 * hash + (this.inactive ? 1 : 0);
        hash = 41 * hash + (this.hasInvoice ? 1 : 0);
        hash = 41 * hash + (this.deliveredBy != null ? this.deliveredBy.hashCode() : 0);
        hash = 41 * hash + (this.shipper != null ? this.shipper.hashCode() : 0);
        hash = 41 * hash + (this.receivedBy != null ? this.receivedBy.hashCode() : 0);
        hash = 41 * hash + (this.shipment != null ? this.shipment.hashCode() : 0);
        hash = 41 * hash + (this.consignee != null ? this.consignee.hashCode() : 0);
        hash = 41 * hash + (this.receiptDetails != null ? this.receiptDetails.hashCode() : 0);
        hash = 41 * hash + (this.createDt != null ? this.createDt.hashCode() : 0);
        hash = 41 * hash + (this.updateDt != null ? this.updateDt.hashCode() : 0);
        hash = 41 * hash + (this.createdBy != null ? this.createdBy.hashCode() : 0);
        hash = 41 * hash + (this.updatedBy != null ? this.updatedBy.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Receipt other = (Receipt) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) {
            return false;
        }
        if (this.number != other.number) {
            return false;
        }
        if (this.pickup != other.pickup) {
            return false;
        }
        if (this.status != other.status) {
            return false;
        }
        if (this.inactive != other.inactive) {
            return false;
        }
        if (this.hasInvoice != other.hasInvoice) {
            return false;
        }
        if ((this.deliveredBy == null) ? (other.deliveredBy != null) : !this.deliveredBy.equals(other.deliveredBy)) {
            return false;
        }
        if (this.shipper != other.shipper && (this.shipper == null || !this.shipper.equals(other.shipper))) {
            return false;
        }
        if (this.receivedBy != other.receivedBy && (this.receivedBy == null || !this.receivedBy.equals(other.receivedBy))) {
            return false;
        }
        if (this.shipment != other.shipment && (this.shipment == null || !this.shipment.equals(other.shipment))) {
            return false;
        }
        if (this.consignee != other.consignee && (this.consignee == null || !this.consignee.equals(other.consignee))) {
            return false;
        }
        if (this.receiptDetails != other.receiptDetails && (this.receiptDetails == null || !this.receiptDetails.equals(other.receiptDetails))) {
            return false;
        }
        if (this.createDt != other.createDt && (this.createDt == null || !this.createDt.equals(other.createDt))) {
            return false;
        }
        if (this.updateDt != other.updateDt && (this.updateDt == null || !this.updateDt.equals(other.updateDt))) {
            return false;
        }
        if (this.createdBy != other.createdBy && (this.createdBy == null || !this.createdBy.equals(other.createdBy))) {
            return false;
        }
        if (this.updatedBy != other.updatedBy && (this.updatedBy == null || !this.updatedBy.equals(other.updatedBy))) {
            return false;
        }
        return true;
    }
}